//
//  AddCommonTeachView.m
//  fitnessmanage
//
//  Created by wujian on 2018/1/17.
//  Copyright © 2018年 zongquankeji. All rights reserved.
//

#import "AddCommonTeachView.h"

@implementation AddCommonTeachView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIScrollView *scrollView = [[UIScrollView alloc] init];
        [self addSubview:scrollView];
        self.scrollView = scrollView;
        
        /**
         白色背景
         */
        UIView *whiteView = [[UIView alloc] init];
        whiteView.backgroundColor = CSWhiteColor;
        [scrollView addSubview:whiteView];
        self.whiteView = whiteView;
        
        /**
         图片
         */
        UIImageView *classImageView = [[UIImageView alloc] init];
        classImageView.layer.cornerRadius = 4;
        classImageView.layer.masksToBounds = YES;
        classImageView.contentMode = UIViewContentModeScaleToFill;
        classImageView.backgroundColor = CSRedColor;
        [whiteView addSubview:classImageView];
        self.classImageView = classImageView;
        
        /**
         课程名字
         */
        UILabel *classLabelName = [[UILabel alloc] init];
        classLabelName.font = TitleBoldFont;
        classLabelName.textColor = CSColorFromRGB(0x212121);
        [whiteView addSubview:classLabelName];
        self.classLabelName = classLabelName;
        
        
        /**
         时间图片
         */
        UIImageView *timerImageView = [[UIImageView alloc] init];
        [whiteView addSubview:timerImageView];
        self.timerImageView = timerImageView;
        
        /**
         时间Label
         */
        UILabel *timerLabel = [[UILabel alloc] init];
        timerLabel.font = SmallFont;
        timerLabel.textColor = CSColorFromRGB(0x999999);
        [whiteView addSubview:timerLabel];
        self.timerLabel = timerLabel;
        
        
        /**
         教练
         */
        CommonBtnView *teachBtnView = [[CommonBtnView alloc] init];
        teachBtnView.titleLabel.text = @"老师/教练";
        teachBtnView.choseLabel.text = @"选择老师/教练";
        teachBtnView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:teachBtnView];
        self.teachBtnView = teachBtnView;
        
        /**
         上课场地
         */
        CommonBtnView *teachPlaceView = [[CommonBtnView alloc] init];
        teachPlaceView.titleLabel.text = @"上课场地";
        teachPlaceView.choseLabel.text = @"选择上课场地";
        teachPlaceView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:teachPlaceView];
        self.teachPlaceView = teachPlaceView;
        
        
        /**
         单节可约人数
         */
        CommonInputView *cardCourseView = [[CommonInputView alloc] init];
        cardCourseView.titleLabel.text = @"单节可约人数";
        cardCourseView.titleTF.keyboardType = UIKeyboardTypeNumberPad;
        [scrollView addSubview:cardCourseView];
        self.cardCourseView = cardCourseView;
        
        
        /**
         最小上课人数
         */
        CommonInputView *minCourseView = [[CommonInputView alloc] init];
        minCourseView.titleLabel.text = @"最小上课人数";
        minCourseView.titleTF.keyboardType = UIKeyboardTypeNumberPad;
        [scrollView addSubview:minCourseView];
        self.minCourseView = minCourseView;
        
        
        /**
         课程排课
         */
        UILabel *teachClassLabel = [[UILabel alloc] init];
        teachClassLabel.font = MidFont;
        teachClassLabel.textColor = CSColorFromRGB(0x999999);
        [scrollView addSubview:teachClassLabel];
        self.teachClassLabel = teachClassLabel;
        
        
        /**
         课程时间
         */
        CommonBtnView *courseTimeView = [[CommonBtnView alloc] init];
        courseTimeView.titleLabel.text = @"课程时间";
        courseTimeView.choseLabel.text = @"选择课程时间";
        courseTimeView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:courseTimeView];
        self.courseTimeView = courseTimeView;
        
        /**
         何时预约开发
         */
        CommonBtnView *openView = [[CommonBtnView alloc] init];
        openView.titleLabel.text = @"何时预约开发";
        openView.choseLabel.text = @"选择何时预约开发";
        openView.choseLabel.textColor = PlaceHoldColor;
        [scrollView addSubview:openView];
        self.openView = openView;
        
        [self setConstraints];
    }
    
    return self;
}


-(void)setConstraints{
    
    [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.mas_equalTo(self);
    }];
    
    /**
     白色背景
     */
    [self.whiteView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     图片
     */
    [self.classImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.mas_equalTo(self.whiteView).offset(15);
        
        make.width.height.mas_equalTo(80);
        
        make.bottom.mas_equalTo(self.whiteView).offset(-15);
    }];
    
    /**
     课程名字
     */
    [self.classLabelName mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.classImageView).offset(12);
        
        make.left.mas_equalTo(self.classImageView.mas_right).offset(15);
    }];
    
    [self.timerImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.classLabelName);
        
        make.top.mas_equalTo(self.classLabelName.mas_bottom).offset(20);
    }];
    
    [self.timerLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(self.timerImageView);
        
        make.left.mas_equalTo(self.timerImageView.mas_right).offset(5);
    }];
    
    /**
     教练
     */
    [self.teachBtnView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.whiteView.mas_bottom).offset(10);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    
    /**
     上课场地
     */
    [self.teachPlaceView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.teachBtnView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
    }];
    
    
    /**
     单节可约人数
     */
    [self.cardCourseView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.teachPlaceView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
    }];
    
    
    /**
     最小上课人数
     */
    [self.minCourseView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.cardCourseView.mas_bottom);
        
        make.left.width.mas_equalTo(self);
    }];
    
    
    
    /**
     课程排课
     */
    [self.teachClassLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
      
        make.top.mas_equalTo(self.minCourseView.mas_bottom).offset(12);
        
        make.left.mas_equalTo(self.scrollView).offset(15);
    }];
    
    /**
     课程时间
     */
    [self.courseTimeView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.teachClassLabel.mas_bottom).offset(15);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    /**
     何时预约开发
     */
    [self.openView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.courseTimeView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
        
        //make.bottom.mas_equalTo(self.scrollView);
    }];
    
    [self setNeedsLayout];
    [self layoutIfNeeded];
    
    self.scrollView.contentSize = CGSizeMake(self.width, self.openView.bottom + 10 + adaptNavagationBar);
}


@end
